# funtion which draw the section contour which show the distribution of atom density
# matr:matrix(list-sublist) of which the values are the atom distribution density
# dspx,dspy:distance between two successive steps in each direction
# nspx,nspy:number of total steps in each direction
# xori,yori:coordiate of the origin

def sectrace(matr,dspx,dspy,nspx,nspy,xori,yori):
    # import numpy as np
    # import matplotlib.pyplot as plt
    plt.figure(1)    # create the figure

    # search the min and max of values in the matrix
    maxi=mini=matr[0,0]  #initialize maxi and mini
    for j in matr:
        if j>maxi:
            maxi=j
        if j<mini:
            mini=j
    V=np.arange(mini,maxi,(maxi-mini)/100)  # define the value of each contour
    X=[xori,xori+(nspx+1)*dspx,dspx] # coordinate the x axis
    Y=[yori,yori+(nspy+1)*dspy,dspy] # coordinate the y axis
    CS=plt.contour(X,Y,matr,V,linewidths=2)
    plt.show()
    return

